using Godot;
using System;
using System.ComponentModel;

public partial class OptionButtons : GridContainer
{
	private Label renderDistanceLabel;
	private Slider renderDistanceSlider;
	private CheckBox fogCheckbox;

	public override void _Ready()
	{
		GD.Print("OptionButtons._Ready()");
		renderDistanceLabel = GetNode<Label>("RenderDistanceLabel");
		renderDistanceSlider = GetNode<Slider>("RenderDistanceSlider");
		fogCheckbox = GetNode<CheckBox>("FogCheckBox");
		Node settings = GetNode<Node>("/root/Settings");
		renderDistanceSlider.Value = (double)settings.Get("render_distance");
		renderDistanceLabel.Text = $"Render distance: {renderDistanceSlider.Value}";
		fogCheckbox.ButtonPressed = (bool)settings.Get("fog_enabled");
	}

	private void RenderDistanceSliderValueChanged(float value)
	{
		GD.Print("RenderDistanceSliderValueChanged");
		
		Node settings = GetNode<Node>("/root/Settings");
		settings.Set("render_distance",renderDistanceSlider.Value);
		renderDistanceLabel.Text = $"Render distance: {renderDistanceSlider.Value}";

		settings.Call("save_settings");
	}
	private void FogCheckBoxPressed()
	{
		GD.Print("FogCheckBoxPressed");
		Node settings = GetNode<Node>("/root/Settings");
		settings.Set("fog_enabled", fogCheckbox.ButtonPressed);
		settings.Call("save_settings");
	}
	
}
